within ThreeD_MBS_Dynamics.Examples.Rattleback;

model Case_of_Kane_Test
  parameter Real g=9.81;
  parameter Real alpha=0.5*Modelica.Constants.pi/180;
  parameter Real beta=0.5*Modelica.Constants.pi/180;
  inner parameter Real[3] Gravity={0,-g,0};

  // Ellipsoid semi-diameters
  inner parameter Real a1=0.2;
  inner parameter Real b1=0.02;
  inner parameter Real c1=0.03;
  inner parameter Real delta=0.01428182891938;
  parameter Real qalpha[4]={cos(alpha/2),sin(alpha/2)*cos(delta),0,-sin(alpha
      /2)*sin(delta)};
  parameter Real qbeta[4]={cos(beta/2),sin(beta/2)*sin(delta),0,sin(beta/2)*
      cos(delta)};
  inner parameter Real h=0.01;
  annotation (Diagram);
  Base Base1(Plane(
      Length=0.01,
      Width=0.5,
      Height=0.5)) annotation (extent=[-60, 0; -40, 20]);
  Case_of_Kane_Rattleback RollingBody1(
    q(start=QMult(qalpha, QMult(qbeta, {1,0,0,0}))),
    r(start={0.0172989203771403,0.0100769534556172,-0.000303278424757918}),
    I=[0.000199714344, 0, 0; 0, 0.0017, 0; 0, 0, 0.001600285656],
    v(start={-0.0503696159308381,0.086491308436296,0.000754798213773296}),
    omega(start={0,5,0})) annotation (extent=[20, 0; 40, 20]);
  Case_of_Kane_Constraint Ellipsoid_on_Plane1 
    annotation (extent=[-20, 0; 0, 20]);
equation
  connect(Base1.InPortRoll, Ellipsoid_on_Plane1.OutPortA) 
    annotation (points=[-50, 19; -50, 30; -13, 30; -13, 19]);
  connect(Base1.OutPort, Ellipsoid_on_Plane1.InPortA) 
    annotation (points=[-50, 1; -50, -10; -13, -10; -13, 1]);
  connect(Ellipsoid_on_Plane1.InPortB, RollingBody1.OutPort) 
    annotation (points=[-7, 1; -7, -10; 30, -10; 30, 1]);
  connect(Ellipsoid_on_Plane1.OutPortB, RollingBody1.InPortRoll) 
    annotation (points=[-7, 19; -7, 30; 30, 30; 30, 19]);
end Case_of_Kane_Test;
